/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.srcptit.trainning.hanhpt.btvn1;

/**
 *
 * @author Administrator
 */
public class Bai7M1 
{
    static boolean nguyento(int n)
    {
       if(n==0||n==1) return false;
       else
           for(int i=2;i<=(int) Math.sqrt(n);i++)
               if(n%i==0) return false;
               return true;
           
    }
    static boolean thuannghic(int n)
    {
        int dao=0;
        int a=n;
        while(n>0)
        {
            dao=dao*10+n%10;
            n=n/10;
        }
        if(dao==a) return true;
        return false;
    }
    static int tong(int n)
    {
        int s=0;
        while(n>0)
        {
            s=s+n%10;
            n=n/10;
        }
        return s;
    }
    static boolean fibo(int n)
    {   int i;
        int [] a=new int[n+1];
        a[0]=1;
        a[1]=1;
        for(i=2;i<=n;i++)
            a[i]=a[i-1]+a[i-2];
        for(i=0;i<=n;i++)
            if(tong(n)==a[i])
                return true;
                return false;
       
    }
    public static void main(String[] args) {
        for(int i=10000;i<=9999999;i++)
            if(nguyento(i)&&thuannghic(i)&&fibo(i))
                System.out.print(i+ " ");
    }
    
    
}
